/**
 * Created by wangshaohua on 2018/1/25.
 */
moduleOrganizationClient.controller("FindOrganizationClient", function (EmsMgtOrganizationClientResource, $scope, $log, $state, $stateParams, LoadingService, ConstantService, DialogService) {
    initPage($scope);
    $scope.$on("ngDialog.opened", function () {
        dialogOnLoad();

        $scope.queryData = {};
    });

    // ------------------------------------------------------------------------------------------------------

    $scope.cancel = function () {
        DialogService.close();
    };

    $scope.query = function () {
        EmsMgtOrganizationClientResource.findByKey({}, {key: $scope.queryKey}, function (result) {
            $scope.organizations = result.data;
        })
    }

    $scope.submit = function (record) {
        Alert.confirm(function () {
            const data = {
                id: record.id,
                parentOrganizationClientId: $scope.parentId
            }
            $scope.$parent.newNode = record;
            EmsMgtOrganizationClientResource.changeParentOrganizationClient({}, data, function () {
                DialogService.close();
            });
        })
    }
});